home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / bookshelf.lua < prev    next >
Text File  |  2004-01-29  |  3KB  |  81 lines

  1. -- bookshelf  state machine
  2.  
  3. beginStateMachine()
  4.  
  5.     onMsg("buildMenu", function(msg)
  6.         if (repairMenu()) then return end
  7.         
  8.         -- build the pie menu
  9.         clearPieMenu();
  10.         local button;
  11.         button = addPieMenuButton("pm_takeBoardgame", "takeBoardgame");
  12.         button.addDescription(ACTIVITY, "playBoardgame");
  13.  
  14.         button = addPieMenuButton("pm_takeNovel", "takeBook", "Novel");
  15.         button.addDescription(ACTIVITY, "readNovel");
  16.  
  17.         button = addPieMenuButton("pm_takeSpecBook", "takeBook", "SpecBook");
  18.         button.addDescription(ACTIVITY, "readSpecBook");
  19.  
  20.     end )
  21.  
  22.     onMsg("takeBoardgame", function(msg)
  23.         -- get the game object server
  24.         local gameObjectServer = getGameObjectServer();
  25.         -- get character who initiated this action
  26.         local character = getStateObjectFromID(msg.sender);
  27.         -- walk to the closest action point
  28.         local actionPoint = character.getFreeActionPoint(this, "take1");
  29.         -- get the walk state object
  30.         local wso = character.walkSO;
  31.         if (actionPoint) then
  32.             -- create state machine contexts
  33.             local wsoContext = StateMachineContext();
  34.             -- store the action point
  35.             wsoContext.storeData("actionPointName", actionPoint.getName());
  36.             wsoContext.storeStateObject("bookshelf", this);
  37.             if (wso.walkToActionPoint(actionPoint)) then
  38.                 wso.queueStateMachine("bookshelfChar.takeBoardgame", this, wsoContext);
  39.             else
  40.                 print("no path found");
  41.                 instantAbort(character, EMOTICON_NOPATH, "emoThink")
  42.             end
  43.         else
  44.             print("no action point found");
  45.             instantAbort(character, EMOTICON_CANNOT, "emoThink")
  46.         end
  47.     end )
  48.     
  49.  
  50.     onMsg("takeBook", function(msg)
  51.         -- get the game object server
  52.         local gameObjectServer = getGameObjectServer();
  53.         -- get character who initiated this action
  54.         local character = getStateObjectFromID(msg.sender);
  55.         -- walk to the closest action point
  56.         local actionPoint = character.getFreeActionPoint(this, "take1");
  57.         -- get the walk state object
  58.         local wso = character.walkSO;
  59.         if (actionPoint) then
  60.             -- create state machine contexts
  61.             local wsoContext = StateMachineContext();
  62.             -- store the action point
  63.             wsoContext.storeData("actionPointName", actionPoint.getName());
  64.             wsoContext.storeData("bookType", msg.data);
  65.             wsoContext.storeStateObject("bookshelf", this);
  66.             if (wso.walkToActionPoint(actionPoint)) then
  67.                 wso.queueStateMachine("bookshelfChar.takeBook", this, wsoContext);
  68.             else
  69.                 print("no path found");
  70.                 instantAbort(character, EMOTICON_NOPATH, "emoThink")
  71.             end
  72.         else
  73.             print("no action point found");
  74.             instantAbort(character, EMOTICON_CANNOT, "emoThink")
  75.         end
  76.     end )
  77.     
  78.  
  79.             
  80. endStateMachine()
  81.